//
//  QYXTalkDetailTableViewCell.m
//  OpenYourEyes
//
//  Created by dllo on 16/6/8.
//  Copyright © 2016年 Google AdWords. All rights reserved.
//

#import "QYXTalkDetailTableViewCell.h"

@implementation QYXTalkDetailTableViewCell



- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.headImageView.layer.cornerRadius = 15;
    self.headImageView.layer.masksToBounds = YES;
    self.nameLabel.font = [UIFont fontWithName:@"FZLTZCHJW--GB1-0" size:13];
    self.timeLabel.font = [UIFont fontWithName:@"FZLTXIHJW--GB1-0" size:11];
    self.timeLabel.textColor = [UIColor lightGrayColor];
    self.detailLabel.font = [UIFont fontWithName:@"FZLTXIHJW--GB1-0" size:11];
    self.goodLabel.font = [UIFont fontWithName:@"FZLTXIHJW--GB1-0" size:11];
    self.hotLabel.font = [UIFont fontWithName:@"Lobster 1.4" size:11];
    self.detailLabel.numberOfLines = 0;
}

- (void)setModel:(QYXTalkReplyListModel *)model
{
    if (_model != model) {
        _model = model;
    }
    [self.headImageView sd_setImageWithURL:[NSURL URLWithString:[_model.user objectForKey:@"avatar"]] placeholderImage:kPlaceHolderImage];
    self.nameLabel.text = [_model.user objectForKey:@"nickname"];
    self.timeLabel.text = [self TimeBy:(NSInteger)_model.createTime];
    self.detailLabel.text = _model.message;
    self.goodImageView.image = [UIImage imageNamed:@"good"];
    self.goodLabel.text = [NSString stringWithFormat:@"%ld", _model.likeCount];
    if (_model.hot == true) {
        self.hotLabel.text = [NSString stringWithFormat:@"-Hot-"];
    }
}

- (NSString *)TimeBy:(NSInteger)number
{
    
    NSTimeInterval time = number + 28800;//因为时差问题要加8小时 == 28800 sec
    
    NSDate *detaildate= [NSDate dateWithTimeIntervalSince1970:time];
    
    //实例化一个NSDateFormatter对象
    
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init] ;
    
    //设定时间格式,这里可以设置成自己需要的格式
    
    [dateFormatter setDateFormat:@"HH:mm"];
    
    return [dateFormatter stringFromDate:detaildate];
    
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
